# Maintainer: Maxime Gauduin <alucryd@archlinux.org>
# Contributor: Daniel Bermond <dbermond@archlinux.org>
# Contributor: Thomas Schneider <maxmusterm@gmail.com>

pkgname=svt-av1
pkgver=1.7.0
pkgrel=1
pkgdesc='Scalable Video Technology AV1 encoder and decoder'
arch=(loong64 x86_64)
url=https://gitlab.com/AOMediaCodec/SVT-AV1
license=(
  BSD
  'custom: Alliance for Open Media Patent License 1.0'
)
depends=(glibc)
makedepends=(
  cmake
  git
  nasm
  ninja
)
_tag=6d5f2b4e1f04db677cdd4ab2b0d6831ab06a849c
source=(git+https://gitlab.com/AOMediaCodec/SVT-AV1.git#tag=${_tag})
b2sums=(SKIP)

prepare() {
  sed '/CMAKE_BUILD_TYPE Release/d' -i SVT-AV1/CMakeLists.txt
}

pkgver() {
  cd SVT-AV1
  git describe --tags | sed 's/^v//'
}

build() {
  export LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
  cmake -S SVT-AV1 -B build -G Ninja \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DBUILD_SHARED_LIBS=ON \
    -DNATIVE=OFF
  ninja -C build
}

package() {
  DESTDIR="${pkgdir}" ninja -C build install
  install -Dm 644 SVT-AV1/{LICENSE,PATENTS}.md -t "${pkgdir}"/usr/share/licenses/svt-av1/
}

# vim: ts=2 sw=2 et:
